home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Adobe Graphics & Publishing SDK 1996 December
/
Adobe Graphics & Publishing SDK 1996 December.iso
/
mac
/
PageMaker 6.5 SDK Mac
/
SourceCode
/
PageMakerClassLibrary
/
LowLevel
/
PPluginCall.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-08-20
|
4KB
|
136 lines
/*
*--- PPluginCall.cpp -----------------------------------------------------
* Copyright (c) 1995-96 Adobe Systems Incorporated. All rights reserved.
* Created on Thu, Oct 12, 1995 @ 9:50 PM by Paul Ferguson.
*
* Description: For notes about this class, refer to the
* header file PPluginCall.h
*-------------------------------------------------------------------------
*/
#include <string.h>
#include "PPluginCall.h"
#include "CIBasic.h"
#include "CIInterfaceManager.h"
#include "PMInterfaceIDs.h"
extern PMMessage * gPMMessage;
extern sPMParamBlockPtr gPB;
sPMParamBlockPtr PPluginCall::sPB = NULL; // Stores the current executing param block
PMMessage * PPluginCall::sPMMessage = NULL;
PPluginCall::PPluginCall()
{
// assert (message != NULL);
sPMMessage = gPMMessage;
sPB = gPB; // it is up to the DoXXX() functions to decide whether they need the Command and Query param block
}
// Static factory function
void PPluginCall::Dispatch()
{
switch (sPMMessage->opCode)
{
case kPMLoad:
DoLoad();
break;
case kPMRegister:
DoRegister();
break;
case kPMInvoke:
DoInvoke();
break;
case kPMEvent:
DoEvent();
break;
case kPMSysEvent:
DoSysEvent();
break;
case kPMAcquireInterface:
DoAcquireInterface();
break;
case kPMReleaseInterface:
DoReleaseInterface();
break;
case kPMUnload:
DoUnload();
break;
case kPMShutdown:
DoShutdown();
break;
default:
return;
break; // do nothing
}
}
/*
*--- BuildErrorMessages ---------------------------------------
* This is a utility routine that takes a string parameter,
* allocates a handle for it, and stuffs it in the
* errMessage field of the parameter block.
*
* Note: The handle becomes property of PageMaker, which
* will free the handle after it's displayed.
*
* BULLSHIT: Does the error message handler still use handles?
* If so, need to restore this function to the
* way it was in 6.0.
*--------------------------------------------------------------
*/
void PPluginCall::BuildErrorMessages(const char * errText, const char * cantText)
{
sPB->errMessage = NULL;
if (errText == NULL)
return;
CIBasic * basicInterface; // = dynamic_cast<CIBasic *> (interface);
gPMMessage->pInterfaceMgr->AcquirePMInterface((unsigned long)PMIID_BASIC, (void **) &basicInterface);
size_t lenErrText = strlen(errText);
size_t lenCantText = cantText ? strlen(cantText) : 0;
//---------------------------------------------------------
// PageMaker requires that its strings be padded to
// even-byte boundaries, and have an extra null character
// at the end of the first or second string, so we add
// a little extra room.
//---------------------------------------------------------
char * ch = (char *) basicInterface->PMMemAlloc(lenErrText + lenCantText + 5);
if (errText)
strcpy(ch, errText);
//---------------------------------------------------------
// The "Can't" message is optional. If it's present,
// PageMaker does not display it's default "Cant" message.
// Make sure to start on even byte boundary.
//---------------------------------------------------------
if (cantText)
{
short i = lenErrText + (lenErrText & 0x01 ? 1 : 2);
strcpy(&ch[i], cantText);
}
sPB->errMessage = (PMHandle) ch;
gPMMessage->pInterfaceMgr->ReleasePMInterface(basicInterface);
}
// end of PPluginCall.cpp